<template>
  <div class="registerview" v-loading.fullscreen.lock="fullscreenLoading">
    <div class="title">使用邮箱注册 </div>
    <hr/>
    <el-form class="registerform" method="post" @submit.prevent="vregister">
      <el-form-item class="user-name">
        <el-input v-model="username" placeholder="用户名"></el-input>
      </el-form-item>
      <el-form-item class="user-pwd">
        <el-input v-model="password" type="password" placeholder="密码"></el-input>
      </el-form-item>
      <el-form-item class="user-cpwd">
        <el-input v-model="confirmPassword" type="password" placeholder="确认密码"></el-input>
      </el-form-item>
      <el-form-item class="user-email">
        <el-input v-model="email" placeholder="邮箱地址"></el-input>
      </el-form-item>
      <el-form-item class="user-tel">
        <el-input v-model="tel" type="text" placeholder="手机号"></el-input>
      </el-form-item>
      <el-form-item class="user-tel">
        <el-button type="primary" id="btn-register" @click="vregister" :loading="registerProcess">注册</el-button>
      </el-form-item>
      <div style="display:none">
        <input type="password" />
      </div>
      <!-- <div class="user-pwd">
                                                  <el-input v-model="password" type="password" placeholder="密码"></el-input>
                                                </div>
                                                <div>
                                                  <el-button type="primary" id="btn-register" native-type="submit">登录</el-button>
                                                </div>
                                                <div class="flex-box flex-end">
                                                  <el-button type="text">忘记密码？</el-button>
                                                </div>
                                                <div class="reg-panel">
                                                  <span>已有账号？</span>
                                                  <a href='/register.html'>立即登录</a>
                                                </div> -->
    </el-form>
  </div>
</template>

<script>
import {
  mapActions,
  mapMutations,
  mapState,
} from 'vuex';

export default {
  name: 'userview',
  data() {
    return {
      username: '',
      password: '',
      email: '',
      confirmPassword: '',
      tel: '',
      registerProcess: false,
    };
  },
  methods: {
    vregister() {
      this.registerProcess = true;
      this.register({
        username: this.username,
        password: this.password,
        email: this.email,
        phone: this.tel,
      }).then(() => {
        location.href = '/login.html';
        this.registerProcess = false;
      }).catch((msg) => {
        this.$message(msg.error);
        this.registerProcess = false;
      });
    },
    ...mapActions(['register']),
    ...mapMutations([]),
  },

  computed: {
    ...mapState({
      fullscreenLoading: state => state.sys.fullscreenLoading,
    }),
  },
  mounted() { },
  components: {},
};
</script>

<style lang="less">
html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
}

.flex-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.flex-box.flex-end {
  justify-content: flex-end;
}

body {
  background: -webkit-gradient(linear, 0 0, right bottom, from(rgba(0, 0, 0, 0.9)), color-stop(.5, #20a0ff), to(#660E0E));
  background-color: #20a0ff;
}

.registerview {
  padding: 1px;
  box-shadow: 0 0 2px;
  width: 90%;
  margin: 0% auto;
  background-color: white;
  position: absolute;
  top: 20%;
  left: 5%;
  .title {
    font-size: 24px;
    padding-left: 40px;
    margin: 10px auto;
  }
  .el-form-item {
    button {
      width: 100%;
      height: 45px;
    }
    input {
      height: 45px;
    }
  }
}

.registerform {
  position: relative;
  max-width: 420px;
  margin: 5% auto;
}

@media screen and (max-width: 560px) {
  .registerview {
    width: 90%;
    left: 5%;
    box-sizing: border-box;
  }
}

@media screen and (min-width: 900px) {
  .registerview {
    width: 800px;
    left: 50%;
    margin-left: -400px;
    box-sizing: border-box;
  }
}
</style>
